<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <title>支付处理中...</title>
  <style>
    body {
      margin: 0;
      padding: 20px;
      text-align: center;
      font-family: system-ui;
      background: #fff;
    }
    .loading {
      margin: 20px 0;
      color: #666;
      font-size: 16px;
    }
    #form-container {
      position: fixed;
      left: -9999px;
      top: -9999px;
    }
  </style>
</head>
<body>
  <div class="loading">正在跳转到支付宝...</div>
  <div id="form-container"></div>
  <script>
    function submitForm() {
      try {
        // 从URL参数获取支付表单HTML
        const urlParams = new URLSearchParams(window.location.search);
        const formHtml = urlParams.get('form');
        
        if (formHtml) {
          // 解码并插入表单
          document.getElementById('form-container').innerHTML = decodeURIComponent(formHtml);
          
          // 获取表单并提交
          const form = document.forms[0];
          if (form) {
            console.log('正在提交支付表单...');
            form.submit();
          } else {
            throw new Error('支付表单不存在');
          }
        } else {
          throw new Error('未获取到支付表单数据');
        }
      } catch (error) {
        console.error('支付表单提交失败：', error);
        document.querySelector('.loading').textContent = '支付跳转失败，请返回重试';
      }
    }

    // 页面加载完成后提交表单
    if (document.readyState === 'loading') {
      document.addEventListener('DOMContentLoaded', submitForm);
    } else {
      submitForm();
    }
  </script>
</body>
</html> 